Soru & Cevap

mysql ve android JSON hatası

04.12.2018 - 04:35

Kolay gelsin.Bir android,mysql projem var ve kayıt yaptırmaya çalışıyorum.value br of type java.lang.string cannot be converted to jsonobject android.Böyle bir hata alıyorum.Nedendir?Ve çözümü nedir?

63 Görüntülenme

10 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user bernaelif06
bernaelif06
05.12.2018 - 12:02


 

 public void onResponse(String response) {
                try{
                    final JSONObject jsonObject=new JSONObject(response);
                  String success= jsonObject.getString("success");
                    if(success.equals("1")){
                        Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show();
                    }

                }
                catch (JSONException e){
                    e.printStackTrace();
                    Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show();
                    loading.setVisibility(View.GONE);
                    btn_regist.setVisibility(View.VISIBLE);
                }

            }
        },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show();
                        loading.setVisibility(View.GONE);
                        btn_regist.setVisibility(View.VISIBLE);

                    }
                })

 

Profile picture for user bernaelif06
bernaelif06
05.12.2018 - 12:01


public void onResponse(String response) { try{ final JSONObject jsonObject=new JSONObject(response); String success= jsonObject.getString("success"); if(success.equals("1")){ Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show(); } } catch (JSONException e){ e.printStackTrace(); Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } })
 

 public void onResponse(String response) {
                try{
                    final JSONObject jsonObject=new JSONObject(response);
                  String success= jsonObject.getString("success");
                    if(success.equals("1")){
                        Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show();
                    }

                }
                catch (JSONException e){
                    e.printStackTrace();
                    Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show();
                    loading.setVisibility(View.GONE);
                    btn_regist.setVisibility(View.VISIBLE);
                }

            }
        },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show();
                        loading.setVisibility(View.GONE);
                        btn_regist.setVisibility(View.VISIBLE);

                    }
                })

 

Profile picture for user bernaelif06
bernaelif06
05.12.2018 - 11:50
 JSONObject jsonObject=new JSONObject(response);
                  String success= jsonObject.getString("success");
                    if(success.equals("1")){
                        Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show();
                    }

                }
                catch (JSONException e){
                    e.printStackTrace();
                    Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show();
                    loading.setVisibility(View.GONE);
                    btn_regist.setVisibility(View.VISIBLE);
                }

            }
        },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show();
                        loading.setVisibility(View.GONE);
                        btn_regist.setVisibility(View.VISIBLE);

                    }

 

picture-84564-1548924191.jpg
emrekaplan606
05.12.2018 - 11:45

response değerinde sıkıntı var galiba. bu satıra breakpoint koyarak debug modda bakabilir misin ? response içeriğini görmüş oluruz. 

Profile picture for user bernaelif06
bernaelif06
05.12.2018 - 11:41
 JSONObject jsonObject=new JSONObject(response);
                  String success= jsonObject.getString("success");
                    if(success.equals("1")){
                        Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show();
                    }

                }
                catch (JSONException e){
                    e.printStackTrace();
                    Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show();
                    loading.setVisibility(View.GONE);
                    btn_regist.setVisibility(View.VISIBLE);
                }

            }
        },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show();
                        loading.setVisibility(View.GONE);
                        btn_regist.setVisibility(View.VISIBLE);

                    }

 

Profile picture for user bernaelif06
bernaelif06
05.12.2018 - 11:41
 JSONObject jsonObject=new JSONObject(response);
                  String success= jsonObject.getString("success");
                    if(success.equals("1")){
                        Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show();
                    }

                }
                catch (JSONException e){
                    e.printStackTrace();
                    Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show();
                    loading.setVisibility(View.GONE);
                    btn_regist.setVisibility(View.VISIBLE);
                }

            }
        },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show();
                        loading.setVisibility(View.GONE);
                        btn_regist.setVisibility(View.VISIBLE);

                    }

 

Profile picture for user bernaelif06
bernaelif06
05.12.2018 - 11:41
 JSONObject jsonObject=new JSONObject(response);
                  String success= jsonObject.getString("success");
                    if(success.equals("1")){
                        Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show();
                    }

                }
                catch (JSONException e){
                    e.printStackTrace();
                    Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show();
                    loading.setVisibility(View.GONE);
                    btn_regist.setVisibility(View.VISIBLE);
                }

            }
        },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show();
                        loading.setVisibility(View.GONE);
                        btn_regist.setVisibility(View.VISIBLE);

                    }

 

Profile picture for user bernaelif06
bernaelif06
05.12.2018 - 11:39
 JSONObject jsonObject=new JSONObject(response);
                  String success= jsonObject.getString("success");
                    if(success.equals("1")){
                        Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show();
                    }

                }
                catch (JSONException e){
                    e.printStackTrace();
                    Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show();
                    loading.setVisibility(View.GONE);
                    btn_regist.setVisibility(View.VISIBLE);
                }

            }
        },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show();
                        loading.setVisibility(View.GONE);
                        btn_regist.setVisibility(View.VISIBLE);

                    }

 

Profile picture for user bernaelif06
bernaelif06
05.12.2018 - 11:38
 JSONObject jsonObject=new JSONObject(response);
                  String success= jsonObject.getString("success");
                    if(success.equals("1")){
                        Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show();
                    }

                }
                catch (JSONException e){
                    e.printStackTrace();
                    Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show();
                    loading.setVisibility(View.GONE);
                    btn_regist.setVisibility(View.VISIBLE);
                }

            }
        },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show();
                        loading.setVisibility(View.GONE);
                        btn_regist.setVisibility(View.VISIBLE);

                    }

 

picture-84564-1548924191.jpg
emrekaplan606
05.12.2018 - 08:31

Merhaba, şu şekilde bir kod parçası var. JSONObject obj = new JSONObject(stringData); burada ki stringData'nın formatı json' a dönüştürülemiyor. Kullandığın web servisi dışarıdan çağırarak geriye dönen datayı incele sorunu çözersin. Kolay gelsin.

berna koç
05.12.2018 - 11:37
Sorun şu ki ne yapacağımı bilmiyorum.İnternetten denilen herşeyi denedim ama olmadı.Yardımcı olursanız sevinirim.